package com.uchiha.nova.core.utils;

import com.uchiha.nova.core.tool.util.StringUtil;
import org.slf4j.MDC;

/**
 * @author 周林静
 * @Date 2021-10-25 17:10
 * @Version 1.0
 */
public class LogTraceUtil {
    private static final String UNIQUE_ID = "traceId";

    /**
     * 获取日志追踪id格式
     */
    public static String getTraceId() {
        return StringUtil.randomUUID();
    }

    /**
     * 插入traceId
     */
    public static boolean insert() {
        MDC.put(UNIQUE_ID, getTraceId());
        return true;
    }

    /**
     * 移除traceId
     */
    public static boolean remove() {
        MDC.remove(UNIQUE_ID);
        return true;
    }

}
